class Solution(object):
    def reverseWords(self, s):
        """
        :type s: List[str]
        :rtype: None Do not return anything, modify s in-place instead.
        """
        s.reverse()
        l_index = 0
        r_index = 0
        out = []
        while r_index < len(s):
            if s[r_index] == ' ':
                temp_r = r_index - 1
                while temp_r > l_index:
                    temp = s[temp_r]
                    s[temp_r] = s[l_index]
                    s[l_index] = temp
                    l_index += 1
                    temp_r -= 1
                l_index = r_index + 1
                r_index += 1
            else:
                r_index += 1
        temp_r = len(s) - 1
        while temp_r > l_index:
            temp = s[temp_r]
            s[temp_r] = s[l_index]
            s[l_index] = temp
            l_index += 1
            temp_r -= 1
        return s

data = Solution()
s = ["t", "h", "e", " ", "s", "k", "y", " ", "i", "s", " ", "b", "l", "u", "e"]
print(data.reverseWords(s))